package main 

import (
	"fmt"
	_"unsafe"
	"strconv"
)
//字符串转基本类型
func main(){

	var str string ="true"
	var b bool 
	//b,_ 接收2个参数  第二个参数忽略
	b,_ = strconv.ParseBool(str)

	fmt.Printf("b type =%T,b value = %v\n",b,b)

	var str2 string = "12345"

	var n1 int64 
	var n2 int

	n1,_ = strconv.ParseInt(str2,10,64)
	n2 = int(n1)

	fmt.Printf("n1 type =%T,n1 val =%v,n2 val=%v\n",n1,n1,n2)

	var str3 string = "123.22"

	var n3 float64 

	n3,_= strconv.ParseFloat(str3,64)
	fmt.Printf("n3 type =%T,n3 val =%v\n",n3,n3)

	//字符串转换为int,失败为0
	var str4 string = "china"
	var n4 int64 

	n4,_=strconv.ParseInt(str4,10,64)
	fmt.Printf("n4 type=%T,n4 val=%v\n",n4,n4)
}